jQuery.noConflict();

jQuery(document).ready(function()
{

	jQuery(".toplevel_page_framework > a").html("Over&rsquo;All");

	/* begin slider upload button */ 
	jQuery('.upload_input').each(function()
	{
		jQuery(this).bind('change focus blur framework', function()
		{	
			$get_div = '#' + jQuery(this).attr('name') + '_preview';
			$src = '<img src ="'+jQuery(this).val()+'" />';
			jQuery($get_div).html('').append($src).find('img');
			
			$g = jQuery(this).attr('title');
			$c = "#up_" + jQuery(this).attr('id');
			$d = jQuery(this).attr('id');
			
			onSelectChange($g, $c, $d);
		});
	});
	
	$set = jQuery('.set_input');
	
	window.get_id = false;
	
	$set.click(function()
	{
		window.get_id = jQuery(this).attr('id');			
	});
	
	window.original_send_to_editor = window.send_to_editor;
	window.send_to_editor = function(html)
	{	
		if (get_id) 
		{
		
			$img = jQuery(html).attr('src') || jQuery(html).find('img').attr('src') || jQuery(html).attr('href');
			jQuery('textarea[name='+get_id+']').val($img).trigger('framework');
			jQuery('input[name='+get_id+']').val($img).trigger('framework');
			get_id = false;
			window.tb_remove();
		}else{
			window.original_send_to_editor(html);
		}
	};
	/* end slider upload button */ 
	
	/* begin update item hidden value */ 
	function onSelectChange($get_id, $check_id, $cur_id){
	 
		if(jQuery($check_id).attr('id') == undefined){
			$get_table = "#update_" + $cur_id;
			var htmlToAdd = "<input type=\"hidden\" name=\"update_id[]\" value=\""+$get_id+"\" id=\"up_slider"+$get_id+"\">";
			jQuery($get_table).append(htmlToAdd);
		} 
	}
	/* end update item hidden value */ 
	

	/* begin update item hidden value */ 
	jQuery("#skin_selector").change(function()
	{	
		
		$val = jQuery(this).val();
		$cur_skin = jQuery(".cur_skin").attr("id");
		$cur_main_menu_color = jQuery(".cur_main_menu_color").attr("id");
		$cur_main_menu_over_color = jQuery(".cur_main_menu_over_color").attr("id");
		$cur_submenu_color = jQuery(".cur_submenu_color").attr("id");
		$cur_submenu_over_color = jQuery(".cur_submenu_over_color").attr("id");
		$cur_sub_menu_over_back_color = jQuery(".cur_sub_menu_over_back_color").attr("id");
		
		if($val == $cur_skin){
			jQuery("#menu_color").val($cur_main_menu_color);
			jQuery(".menu_color_bg .ColorPickerDivSample").css("background-color", $cur_main_menu_color);
			jQuery("#menu_hover_color").val($cur_main_menu_over_color);
			jQuery(".hover_color_bg .ColorPickerDivSample").css("background-color", $cur_main_menu_over_color);	
			
			jQuery("#submenu_color").val($cur_submenu_color);
			jQuery(".submenu_color_bg .ColorPickerDivSample").css("background-color", $cur_submenu_color);	
			jQuery("#submenu_hover_color").val($cur_submenu_over_color);
			jQuery(".submenu_over_color_bg .ColorPickerDivSample").css("background-color", $cur_submenu_over_color);	

			jQuery("#submenu_hover_background_color").val($cur_sub_menu_over_back_color);
			jQuery(".submenu_hover_background_color_bg .ColorPickerDivSample").css("background-color", $cur_sub_menu_over_back_color);	
			
		}else{
		
			switch($val){
				case "deep_ocean":
					setcolors("#385064","#6796af","#ffffff","#6796af","#161e26");	
				break;
				case "pink":
					setcolors("#5a3154","#b66cb1","#ffffff","#af67ae","#261623");
				break;
				case "gray":
					setcolors("#555555","#999999","#ffffff","#999999","#111111");
				break;
				case "green":
					setcolors("#698049","#99b66c","#ffffff","#99b66c","#171e12");
				break;
				case "red":
					setcolors("#6a2b2e","#b95460","#ffffff","#b95460","#1c0d0d");
				break;
				case "orange":
					setcolors("#555555","#999999","#ffffff","#999999","#111111");
				break;
		
			}
		
		}
		
	});
	/* end update item hidden value */ 
	
	
	function setcolors($cal1, $cal2, $cal3, $cal4, $cal5){
		jQuery("#menu_color").val($cal1);
		jQuery(".menu_color_bg .ColorPickerDivSample").css("background-color", $cal1);
		
		jQuery("#menu_hover_color").val($cal2);
		jQuery(".hover_color_bg .ColorPickerDivSample").css("background-color", $cal2);
		
		jQuery("#submenu_color").val($cal3);
		jQuery(".submenu_color_bg .ColorPickerDivSample").css("background-color", $cal3);	
		
		jQuery("#submenu_hover_color").val($cal4);
		jQuery(".submenu_over_color_bg .ColorPickerDivSample").css("background-color", $cal4);	

		jQuery("#submenu_hover_background_color").val($cal5);
		jQuery(".submenu_hover_background_color_bg .ColorPickerDivSample").css("background-color", $cal5);
	}
	
	/* begin slider live preview */
	jQuery(".livepic").each(function(){
	
		jQuery(this).mouseover(function(){
			
			$sx = ".livepreview"+jQuery(this).attr('id');
			$sh = ".liveimg"+jQuery(this).attr('id');
			$gi = ".checkimg"+jQuery(this).attr('id');
			$ci = jQuery(this).attr('id');
			$imgpath = jQuery($sh).attr('id');
				
			if(jQuery($gi).attr('id') == undefined){
				var htmlToAdd = "<img class=\"checkimg"+$ci+"\" id=\""+$ci+"\" src='"+$imgpath+"' alt=\"\" style=\"background-color:#15161a;\" />";
				jQuery($sh).append(htmlToAdd);
			}

			jQuery($sx).hide().fadeIn("fast");
			
		}).mouseout(function(){
			
			$sx = ".livepreview"+jQuery(this).attr('id');
			jQuery($sx).fadeOut("fast");

		});
	});
	/* end slider live preview */
	
	/* check update item selecbox */
	jQuery(".new_selectbox").change(function()
	{	
		$g = jQuery(this).attr('title');
		$c = "#up_" + jQuery(this).attr('id');
		$d = jQuery(this).attr('id');
		
		onSelectChange($g, $c, $d);
	});
	
	
	/* check update item texts */
	jQuery(".new_slider").bind('change', function()
	{	
		$g = jQuery(this).attr('title');
		$c = "#up_" + jQuery(this).attr('id');
		$d = jQuery(this).attr('id');
		
		onSelectChange($g, $c, $d);	
	});
	
	/* slider edit button */
	jQuery("a.editme").click(function(){
	
		$ne = "#edit"+jQuery(this).attr('id');
		$active = "#editactive"+jQuery(this).attr('id');
		
		jQuery($ne).fadeIn("slow");
		jQuery($active).hide();
		
		return false;
	});
	
		
	
	// type buttons
	jQuery(".types input:radio").click(function() {
		
		$get_val = jQuery(this).attr('value');
		
		if($get_val == "video"){
			jQuery(".upload_tab").hide();
		}else{
			jQuery(".upload_tab").show();
		}
		
		$g = jQuery(this).attr('title');
		$c = "#up_" + jQuery(this).attr('id');
		$d = jQuery(this).attr('id');
		
		onSelectChange($g, $c, $d);
	});
	
	jQuery("a.slider_set").click(function(){
		jQuery("#setHolder").hide();
		jQuery("#setHolder").fadeIn("normal");
		return false;
	});
	
	
	jQuery("a.set_remove").click(function(){
		jQuery("#setHolder").fadeOut("normal");
		return false;
	});
	
	
	jQuery("a.result_remove").click(function(){
		jQuery("#mysqlresult").fadeOut("normal");
		return false;
	});
	
	jQuery("a.removedit").click(function(){
		$del_upload = "#up_slider" + jQuery(this).attr('id');
		$fade_table = "#edit" + jQuery(this).attr('id');
		$editactive = "#editactive" + jQuery(this).attr('id');
		jQuery($fade_table).hide();
		jQuery($editactive).fadeIn("normal");
		jQuery($del_upload).remove();
		return false;
	});
	
	jQuery('#choose_click_2').click(function(){
		jQuery('#choose1').hide();
        jQuery('#choose2').fadeIn("slow");
    });
    
	jQuery('#choose_click_1').click(function(){
		jQuery('#choose2').hide();
		jQuery('#choose1').fadeIn("slow");
    });

	
	jQuery('#page_template').each(function()
	{
		if(jQuery(this).val() != "page_portfolio.php"){
			jQuery("#portfolio_columns").attr("name", "");
		}else{
			jQuery("#portfolio_columns").attr("name", "portfolio_columns");
		}  
	
		jQuery(this).bind('change focus blur framework', function()
		{
			$val = jQuery(this).val();
			
			
			
			if($val != "default" && $val != "page_full_witdh.php" && $val != "page_contact.php"){
				jQuery(".info_desc").hide();
			}else{
				jQuery(".info_desc").fadeIn("normal");
			}
			
			if($val == "page_portfolio.php"){
				jQuery(".show_portfolio_details").fadeIn("normal");
				jQuery("#template_checker").attr("checked", true);
				$get_width = jQuery("#get_width").val();
				$get_height = jQuery("#get_height").val();
				$get_padding = jQuery("#get_padding").val();
				$get_limit = jQuery("#get_limit").val();
				
				jQuery("#portfolio_thumb_width").val($get_width);
				jQuery("#portfolio_thumb_height").val($get_height);
				jQuery("#portfolio_padding").val($get_padding);
				jQuery("#portfolio_limit").val($get_limit);
				
				jQuery("#portfolio_columns").attr("name", "portfolio_columns");
				jQuery("#portfolio_id").attr("name", "portfolio_id");
				jQuery("#title_desc_detail").attr("name", "title_desc_detail");
				
				jQuery("#title_text").attr("name", "title_text");
				jQuery("#detail_text").attr("name", "detail_text");
				jQuery("#desc_text").attr("name", "desc_text");
				jQuery("#do_filter").attr("name", "do_filter");
				
			}else{

				jQuery(".show_portfolio_details").hide();
				jQuery("#template_checker").attr("checked", false);
				jQuery("#portfolio_thumb_width").val("");
				jQuery("#portfolio_thumb_height").val("");
				jQuery("#portfolio_limit").val("");
				jQuery("#portfolio_padding").val("");
				jQuery("#portfolio_columns").attr("name", "");
				jQuery("#portfolio_id").attr("name", "");
				jQuery("#title_text").attr("name", "");
				jQuery("#detail_text").attr("name", "");
				jQuery("#desc_text").attr("name", "");
				jQuery("#do_filter").attr("name", "");
			}
			
			if($val == "page_blog.php"){
			
				$get_blog_width = jQuery("#get_blog_width").val();
				$get_blog_height = jQuery("#get_blog_height").val();
				$get_blog_limit = jQuery("#get_blog_limit").val();
				
				jQuery("#blog_thumb_width").val($get_blog_width);
				jQuery("#blog_thumb_height").val($get_blog_height);
				jQuery("#blog_limit").val($get_blog_limit);
				jQuery(".show_blog_details").fadeIn("normal");
				jQuery("#blog_id").attr("name", "blog_id");
			}else{
			
				jQuery(".show_blog_details").hide();
				jQuery("#blog_thumb_width").val("");
				jQuery("#blog_thumb_height").val("");
				jQuery("#blog_limit").val("");
				jQuery("#blog_id").attr("name", "");
			}
			
		});
	});
	
	
	jQuery('#portfolio_columns').each(function()
	{
		jQuery(this).bind('change focus blur framework', function()
		{
			$get_width = jQuery("#get_width").val();
			$get_height = jQuery("#get_height").val();
			$get_padding = jQuery("#get_padding").val();
			$get_columns = jQuery("#get_columns").val();
			$get_limit = jQuery("#get_limit").val();
			
			$val = jQuery(this).val();
			
			var arrwidth =new Array(450, 450, 280, 210, 160, 135, 115, 100, 90, 80);
			var arrheight =new Array(250, 250, 150, 125, 100, 100, 90, 90, 90, 80);
			var arrpad =new Array(10,35,41,20,24,14,10,9,5,4);
			var arrlimit =new Array(10,8,9,16,15,18,21,24,27,30);
			
			$height = arrheight[$val-1];
			$width = arrwidth[$val-1];
			$padding = arrpad[$val-1];
			$limit = arrlimit[$val-1];
			
			if($val != $get_columns){
				jQuery("#portfolio_thumb_width").val($width);
				jQuery("#portfolio_thumb_height").val($height);
				jQuery("#portfolio_padding").val($padding);
				jQuery("#portfolio_limit").val($limit);
			}else{
				jQuery("#portfolio_thumb_width").val($get_width);
				jQuery("#portfolio_thumb_height").val($get_height);
				jQuery("#portfolio_padding").val($get_padding);
				jQuery("#portfolio_limit").val($get_limit);
			}
			

		});
	});
});